package com.gem.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gem.entity.Order;
import com.gem.entity.User;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author 刘聪
 * Created  on 2021/3/2
 */
public interface UserMapper extends BaseMapper<User> {
    /**
     * 查询订单
     * @param id
     * @return
     */
    @Select("SELECT o.* FROM sb_order o JOIN sb_user u ON o.user_id=u.id WHERE u.id=#{id}")
    List<Order> orderList(Integer id);


    @Select("SELECT * FROM sb_user WHERE id = #{id}")
    User selectById(Integer id);

    @Select("SELECT * FROM sb_user WHERE name = #{name}")
    User selectByName(String name);
}
